package com.noahedu.style.ui;

import android.app.Activity;
import android.os.Bundle;
import android.text.method.LinkMovementMethod;
import android.text.style.MetricAffectingSpan;
import android.text.style.URLSpan;
import android.text.style.UpdateAppearance;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

import com.noahedu.style.R;
import com.noahedu.style.html2.Html;

/**
 * CharacterStyle
 * 
 * The classes that affect character-level text formatting extend this
 * class.  
 * 
 */
public class Test_CharActivity extends Activity
{

	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.test_char_layout);

		
		TextView tocharV = (TextView)findViewById(R.id.content);
		
		
		
		
		setText(tocharV);
		
		
		
	}

	/**
	 * 自定义标签
	 * 
	 * 系统支持标签<font> <br> ...
	 * 
	 * 
	 *@param tocharV
	 */
	private void setText(TextView tocharV)
	{
		StringBuffer sb = new StringBuffer();
		
		//字体大小
		sb.append("<h1>标题1</h1>");
		sb.append("<h5>标题5</h5>");
		
		//前景色 
		sb.append("<back>后景色</back>");
		sb.append("<br>");
		sb.append("<font color='#ffffff'>景色</font>");//系统支持标签。属性 color .face
		
		
		
		//简单的=== RasterizerSpan，StrikethroughSpan
		sb.append("<strike>strike样式</strike>");//系统支持标签。
		sb.append("<br>");
		sb.append("<raster> RasterizerSpan样式????</raster>");/////////???
		sb.append("<br>");
		sb.append("<maskfilter> MaskFilterSpan样式</maskfilter>");
		sb.append("<br>");
		sb.append("<u> UnderlineSpan</u>");
		
		
		//ClickableSpan
		sb.append("<br>");
		sb.append("<a href=''> ClickableSpan</a>");
		sb.append("<br>");
		//扩展href ，color  ，underline
		sb.append("<a href='' color='red' underline='false'> ClickableSpan</a>");
		
		
		//***********MetricAffectingSpan********/
		sb.append("<br>");
		sb.append("<note text='diao'>钓</note><note text='diao'>鱼</note><note text='diao'>" +
				"岛</note><note text='diao'>是</note><note text='diao'>中</note><note text='diao'>国</note><note text='diao'>的</note>！");
		/*
		 * 错误的是
		 * <note text='diao'>钓鱼岛是中国的！</note>
		 * 注意：characterStyle是字符级别的！！！
		 */
		
		
		//html2
		tocharV.setText(com.noahedu.style.html2.Html.fromHtml(sb.toString()));
//		tocharV.setMovementMethod(new LinkMovementMethod());
//		自定义Method ，tocharV.setMovementMethod(new LinkMovementMethod());
		
		
		
	}
}
